/**
 * 
 */
package org.mspring.mlog.web.module.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.mspring.mlog.entity.security.User;
import org.mspring.mlog.service.security.UserService;
import org.mspring.mlog.web.security.SecurityUtils;
import org.mspring.platform.utils.StringUtils;
import org.mspring.platform.web.freemarker.widget.stereotype.Widget;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author Gao Youbo
 * @since 2013-6-8
 * @description
 * @TODO
 */
@Widget
@RequestMapping("/")
public class Web_UserWidget extends Web_AbstractWidget {
    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public String login(HttpServletRequest request, HttpServletResponse response, Model model) {
        User user = SecurityUtils.getCurrentUser(request);
        if (user != null) {
            return "redirect:/";
        }
        return "skin:/login";
    }

    @RequestMapping("/register")
    public String register(HttpServletRequest request, HttpServletResponse response, Model model) {
        return "skin:/register";
    }

    @RequestMapping("/register/do")
    public String register_do(HttpServletRequest request, HttpServletResponse response, Model model) {
        return "skin:/register";
    }
}
